Hệ thống quản lý ISP trong PHP

1 <?php
2     require_once
'includes/headx.php';
3     require_once
"includes/classes/admin-class.php";
4     $admins =
new Admins($dbh);
5     $page = isset($_GET[
'p' ])?$_GET[ 'p' ]:'';
6
7     
if($page == 'add'){
8             $name = htmlentities($_POST[
'name']);
9             
if (!$admins->addNewCategory($name))
10             {
11                 echo
"Sorry Data could not be inserted !";
12             }
else {
13                 echo
" Data inserted !";
14             }
15     }
else if($page == 'del'){
16         $id = $_POST[
'id'];
17         
if (!$admins->deleteCategory($id))
18         {
19             echo
"Sorry Data could not be deleted !";
20         }
else {
21             echo
"Well! You've successfully deleted a product!";
22         }
23
24     }
else if($page == 'edit'){
25         $name = $_POST[
'name'];
26         $price = $_POST[
'price'];
27         $id = $_POST[
'id'];
28         
if (!$admins->updateCategory($id, $name))
29         {
30             echo
"Sorry Data could not be inserted !";
31         }
else {
32
33             $commons->redirectTo(SITE_PATH.
'categories.php');
34             
35         }
36
37     }
else{
38
39         $categories = $admins->getCategories();
40         
if (isset($categories) && sizeof($categories) > 0){
41             
foreach ($categories as $category){
42                 ?>
43             <tr>
44                 <td><?=$category->cat_id?></td>
45                 <td><?=$category->cat_name?></td>
46                 <td>
47                     <button type=
"button" class="btn btn-success btn-sm" id="edit" data-toggle="modal" data-target="#edit-<?=$category->cat_id?>">EDIT</button>
48                     <!-- Update modal -->
49                     <div
class="fade modal" id="edit-<?=$category->cat_id?>">
50                         <div
class="modal-dialog" role="document">
51                             <div
class="modal-content">
52                                 <div
class="modal-header">
53                                     <button type=
"button" class="close" data-dismiss="modal">×</button>
54                                     <h4>Edit Category</h4>
55                                 </div>
56                                 <form method=
"POST" action="categories_approve.php?p=edit">
57                                     <div
class="modal-body">
58                                         <input type=
"hidden" id="<?=$category->cat_id?>" value="<?=$category->cat_id?>">
59                                         <div
class="form-group has-success">
60                                             <label
for="name">Name</label>
61                                             <input type=
"text" class="form-control" id="nm-<?=$category->cat_id?>" value="<?=$category->cat_name?>" required>
62                                         </div>
63                                     </div>
64                                     <div
class="modal-footer">
65                                         <button type=
"submit" onclick="upData(<?=$category->cat_id?>)" class="btn btn-primary">Update</button>
66                                         <a href=
"#" class="btn btn-warning" data-dismiss="modal">Cancel</a>
67                                     </div>
68                                 </form>
69                             </div>
70                         </div>
71                     </div>
72                     <button type=
"button" id="delete" onclick="delData(<?=$category->cat_id?>)" class="btn btn-warning btn-sm">DELETE</button>
73                 </td>
74             </tr>
75         <?php }
76         }
77     }
78 ?>


Gõ tìm kiếm nhanh...